package views;

import java.util.List;

import com.evaluity.R;

import logic.University;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.TextView;

public class UniversityAdapter extends ArrayAdapter<University>{
	private final Context context;
	private final List<University> values;
	
	public UniversityAdapter(Context _context, List<University> _values) {
		super(_context,R.layout.university_item,_values);
		context = _context;
		values = _values;
	}
	
	//tots els components q usen adapters, contenen un getView
	//view grup = pare contenedor
	@Override
	public View getView(int position, View converView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View rowView = inflater.inflate(R.layout.university_item, parent, false);
		
		TextView nomLabel = (TextView)rowView.findViewById(R.id.nomLabel);
		nomLabel.setText(values.get(position).getNom()+" ("+values.get(position).getSiglas()+")");
		
		ImageView logoView = (ImageView)rowView.findViewById(R.id.logoView);
		logoView.setImageBitmap(values.get(position).getLogo());
		
		
		
		return rowView;
	}
}
